package com.epam.run;

import java.io.IOException;
import java.util.Scanner;
import java.util.logging.LogManager;
import java.util.logging.Logger;

import com.epam.airlines.Airlines;

public class Runner {

	public static void main(String[] args) {
		try {
            LogManager.getLogManager().readConfiguration(
                    Runner.class.getResourceAsStream("/logging.properties"));
        } catch (IOException e) {
            System.err.println("Could not setup logger configuration: " + e.toString());
        }
		Scanner sc = new Scanner(System.in);
		// entering the info from console
		System.out.println("Enter the number of aircrafts: ");
		int n = sc.nextInt();
		System.out.println("Enter the range of fuel consumption "
				+ "to search (min): ");
		int min = sc.nextInt();
		System.out.println("Enter the range of fuel consumption "
				+ "to search (max): ");
		int max = sc.nextInt();
		System.out.println("Enter the number of launches to make: ");
		int numOfLaunches = sc.nextInt();
		sc.close();
		// creating an Airline company
		Airlines airlines = new Airlines();
		for (int i = 0; i < n; i++) {
			airlines.purchaseRandomCraft();
		}
		airlines.launchAirplane(numOfLaunches);
		// show all airplanes
		Logger logger = Logger.getLogger(Airlines.class.getName());
		logger.info(airlines.listAllAirplanes());
		// Printing the required info
		logger.info(airlines.printTotals());
		// printing the airplanes found by the consumption range
		logger.fine(airlines.findByConsumption(min, max));
		SerializationTest.serialize(airlines);

	}
}
